<template>
  <div class="appCenter-group">
    <div :id="anchor" class="appCenter-group__title">{{ name }}</div>
    <div class="appCenter-group__content">
      <div v-for="app of apps" :key="app.id" class="app-item">
        <a :href="app.url" target="_blank" class="app-item__body">
          <!-- <span class="app-item__collect"></span> -->
          <div class="app-item__left">
            <img :src="getImage(app.icon)" :alt="app.name" class="app-item__logo" />
          </div>
          <div class="app-item__right">
            <a-tooltip :content="app.desc" position="bottom">
              <div class="app-item__name">{{ app.name }}</div>
            </a-tooltip>
          </div>
        </a>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { defineProps } from 'vue';
import type { AppGroupRecord } from '@/api/app-center';

defineProps<AppGroupRecord>();

// 动态获取图片路径
function getImage(name: string) {
  // 注意路径是相对于当前文件的
  return new window.URL(`../../../assets/images/app/${name}.jpg`, import.meta.url).href;
}
</script>

<style lang="less" scoped>
.appCenter-group {
  padding-left: 31px;
  box-sizing: border-box;

  &:first-child {
    padding-top: 24px;
  }

  &__title {
    padding: 7px 0 24px 0;
    font-weight: 500;
    font-size: 14px;
    line-height: 14px;
    color: #03081a;
  }

  .app-item {
    display: inline-block;
    background: #fff;
    border-radius: 7px;
    height: 84px;
    width: 246px;
    display: inline-block;
    cursor: pointer;
    position: relative;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    margin-right: 24px;
    margin-bottom: 23px;

    &:hover {
      box-shadow: 3px 0 12px #e5ecf1;
    }

    &__body {
      padding: 15px 0 15px 18px;
      width: 100%;
      display: inline-block;
    }

    &__collect {
      width: 24px;
      height: 24px;
      background-size: 24px 24px;
      background-position: 50%;
      background-repeat: no-repeat;
      right: 8px;
      top: 8px;
      position: absolute;
      display: inline-block;
    }

    &__left,
    &__right {
      display: table-cell;
      vertical-align: middle;
    }

    &__left {
      width: 54px;
    }

    &__logo {
      height: 54px;
      width: 54px;
      border-radius: 15px;
      vertical-align: bottom;
    }

    &__right {
      padding-left: 15px;
      position: relative;
    }

    &__name {
      color: #495366;
      max-width: 160px;
      font-weight: 700;
      font-weight: 500;
      font-size: 15px;
    }

    &__describe {
      background: #000;
      mix-blend-mode: normal;
      opacity: .8;
      border-radius: 8px;
      padding: 8px 12px;
      font-weight: 400;
      font-size: 14px;
      line-height: 20px;
      color: #fff;
      position: absolute;
      left: 50%;
      white-space: nowrap;
      transform: translateX(-50%);
      bottom: -30px;
      margin-left: 4px;
      display: none;
    }

    &__describe-arrow {
      width: 0;
      height: 0;
      border-style: solid;
      border-width: 0 4px 4px 4px;
      border-color: transparent transparent #000 transparent;
      position: absolute;
      top: -4px;
      left: 50%;
      margin-left: -2px;
    }
  }

  @media (max-width: 1050px) {
    .app-item {
      width: 30%;
      margin-right: 3%;
      min-width: 190px;
    }
  }
}
</style>
